package com.dfec.weather.servelet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.dfec.utils.HttpRequest;
import com.dfec.utils.ResponseUtil;

/**
 * Servlet implementation class China2HRforcast
 */
@WebServlet(name = "2hrf", description = "中国天气网两小时降水预报数据", urlPatterns = { "/2hrf" })
public class China2HRforcast extends HttpServlet {
	private static final long serialVersionUID = 1L;
     @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    	// TODO Auto-generated method stub
    	String lat= req.getParameter("lat");
    	String lng= req.getParameter("lng");
    	String jsonList=HttpRequest.sendGet("http://d3.weather.com.cn/webgis_rain_new/webgis/minute",
					"lat="+lat+"&lon="+lng+"&stationid=1&callback=fc5m&_="+System.currentTimeMillis(),1,null,null);
		String jsonStr = jsonList.replace("/**/fc5m(", "").replace(");", "");
		System.out.println(jsonStr);
		
		//ResponseUtil.sendScript(resp, jsonStr.toString());
    }
}
